package com.cn.wanxi.servlet;

import com.cn.wanxi.model.NewsPlateModel;
import com.cn.wanxi.service.INewsPlateService;
import com.cn.wanxi.service.impl.NewsPlateServiceImpl;
import net.sf.json.JSONArray;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/newsPlate")
public class NewsPlateServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        INewsPlateService newsPlateService=new NewsPlateServiceImpl();

        List<NewsPlateModel> newsPlateModelList=newsPlateService.findAll();

        JSONArray jsonArray = JSONArray.fromObject(newsPlateModelList);
        resp.getWriter().println(jsonArray);
    }
}
